package com.zhentao.controller;

import com.zhentao.carouselimage.domain.Carouselimage;
import com.zhentao.carouselimage.dto.CarouseLimageDto;
import com.zhentao.common.dtos.ResponseResult;
import com.zhentao.service.CarouselimageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@Api("/Clmanage")
@Slf4j
@RestController
@RequestMapping("/Clmanage")
public class ManageCarouseLimageController {

    @Resource
    private CarouselimageService carouselimageService;

    /**
     * 后端 轮播图列表
     * @param dto
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "CarouseLimageDto", name = "dto", value = "", required = true)
    })
    @ApiOperation(value = "后端 轮播图列表", notes = "后端 轮播图列表", httpMethod = "POST")
    @PostMapping("/ClList")
    public ResponseResult ClList(@RequestBody CarouseLimageDto dto){
        return carouselimageService.ClListAll(dto);
    }

    /**
     * 后端 轮播图设置 使用 禁用 逻辑删除
     * @param cl 传 id
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Carouselimage", name = "cl", value = "传 id", required = true)
    })
    @ApiOperation(value = "后端 轮播图设置 使用 禁用 逻辑删除", notes = "后端 轮播图设置 使用 禁用 逻辑删除", httpMethod = "POST")
    @PostMapping("/UpClStatus")
    public ResponseResult UpClStatus(@RequestBody Carouselimage cl){
        return carouselimageService.UpClStatus(cl);
    }

    /**
     * 后端 轮播图添加
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "Carouselimage", name = "cl", value = "", required = true)
    })
    @ApiOperation(value = "后端 轮播图添加", notes = "后端 轮播图添加", httpMethod = "POST")
    @PostMapping("/saveCl")
    public ResponseResult saveCl(@RequestBody Carouselimage cl){
        return carouselimageService.saveCl(cl);
    }

    /**
     * 添加图片
     * @param file
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "form", dataType = "file", name = "multipartFile", value = "", required = true)
    })
    @ApiOperation(value = "添加图片", notes = "添加图片", httpMethod = "POST")
    @PostMapping("/uploadImage")
    public ResponseResult uploadImage(MultipartFile file){
        return carouselimageService.saveImage(file);
    }


}
